//
//  FPLoanDetailBarrierView.m
//  FinanceProject
//
//  Created by 陈显摆 on 2025/2/8.
//

#import "FPLoanDetailBarrierView.h"

#define PointWidth 24.f

@interface FPLoanDetailBarrierView ()

@property (nonatomic , strong) UIView *pointView1;
@property (nonatomic , strong) UIView *pointView2;
@property (nonatomic , assign) NSInteger originIndex;

@end

@implementation FPLoanDetailBarrierView

// v2版本 只有"待还款" 
- (UIView *)pointView1 {
    
    if (!_pointView1) {
        
//        _pointView1 = [[UIView alloc] init];
    }
    return _pointView1;
}

- (UIView *)pointView2 {
    
    if (!_pointView2) {
        
//        _pointView2 = [[UIView alloc] init];
    }
    return _pointView2;
}

- (void)awakeFromNib {
    
    [super awakeFromNib];
    
    self.backgroundColor = MAIN_VIEW_BACKGROUND_COLOR;
    
    self.pointView1.frame = CGRectMake(16.f, 28.f, PointWidth, 2.f);
    [self addSubview:self.pointView1];
    
    self.pointView2.frame = CGRectMake(88.f, 28.f, PointWidth, 2.f);
    [self addSubview:self.pointView2];
    
    self.pointView1.backgroundColor = MAIN_BLUE_COLOR;
    self.pointView2.backgroundColor = MAIN_BLUE_COLOR;
    
    [self.pointView1 setCenterX:self.lab1.centerX];
    [self.pointView2 setCenterX:self.lab2.centerX];
    
    self.pointView1.hidden = YES;
    self.pointView2.hidden = YES;
}

- (void)showStatusWithIndex:(NSUInteger)index {
    
    self.originIndex = index;
    
    if (index == 0) {
        
        self.pointView1.hidden = NO;
        self.pointView2.hidden = YES;
        self.lab1.font = BFONT(16.f);
        self.lab2.font = FONT(14.f);
    }
    else {
        
        self.pointView2.hidden = NO;
        self.pointView1.hidden = YES;
        self.lab2.font = BFONT(16.f);
        self.lab1.font = FONT(14.f);
    }
}

- (void)changeStatusWithIndex:(NSUInteger)index {
    
    if (self.originIndex == 0) {
        
        self.pointView2.hidden = NO;
        self.pointView2.transform = CGAffineTransformMakeScale(0, 1);
    }
    else {
        self.pointView1.hidden = NO;
        self.pointView1.transform = CGAffineTransformMakeScale(0, 1);
    }
    
    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        
        if (index == 0) {
            
            self.lab1.transform = CGAffineTransformMakeScale(1.1, 1.1); // 稍微放大 1.1 倍
            self.lab1.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold]; // 切换为粗体，字号 16
            
            self.lab2.transform = CGAffineTransformIdentity; // 恢复原始大小
            self.lab2.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular]; // 常规字体
            
            self.pointView1.transform = CGAffineTransformIdentity;
            self.pointView2.transform = CGAffineTransformMakeScale(0, 1);
        }
        else {
            
            self.lab2.transform = CGAffineTransformMakeScale(1.1, 1.1); // 稍微放大 1.1 倍
            self.lab2.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold]; // 切换为粗体，字号 16
            
            self.lab1.transform = CGAffineTransformIdentity; // 恢复原始大小
            self.lab1.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular]; // 常规字体
            
            self.pointView1.transform = CGAffineTransformMakeScale(0, 1);
            self.pointView2.transform = CGAffineTransformIdentity;
        }
        
    } completion:^(BOOL finished) {
        
    }];
}




@end
